<template>

  <div>

    <div class="price-detail-class" v-if="row.billCategory !== 'TENANT'">
      <div class="price-detail-left-class">计价单位:</div>
      <div  class="price-detail-right-class" >{{ $enumShow(row.priceResult.chargeType, 'PmsChargeTypeEnum') }}</div>
    </div>
    <div v-if="row.priceResult.priceType" class="price-detail-class">
      <div class="price-detail-left-class">计价模式:</div>
      <div  class="price-detail-right-class" >{{ $enumShow(row.priceResult.priceType, 'PmsTransportPriceTypeEnum') }}</div>
    </div>

    <!--计算方式 -->
    <!--    首重-->
    <div v-if="row.priceResult.viewType == 'FIRST'" class="price-detail-class">
      <div class="price-detail-left-class">计算方式:</div>
      <div  class="price-detail-right-class" >{{ row.priceResult.calFirstNums }} {{ row.priceResult.weightUnit }} 以下,金额:{{row.priceResult.amount}}</div>
    </div>

    <!--    首重 + 续重 -->
    <div v-else-if="row.priceResult.viewType == 'ADD'" class="price-detail-class">
      <div class="price-detail-left-class">计算方式:</div>
      <div  class="price-detail-right-class" >
        首重价 {{ row.priceResult.calFirstPrice }} + 续重价 {{ row.priceResult.calAddPrice }} * (重量 {{ row.priceResult.calNums }} - 首重 {{row.priceResult.calFirstNums}})
      </div>
    </div>

    <!--    总价-->
    <div v-else-if="row.priceResult.viewType == 'TOTAL'" class="price-detail-class">
      <div class="price-detail-left-class">计算方式:</div>
      <div  class="price-detail-right-class" >
        {{ getChargeUnitBy(row.priceResult.chargeType) + ' ' + row.priceResult.calNums + getChargeUnitName(row.priceResult.chargeType, row.priceResult.weightUnit) }} ,
        {{ row.priceResult.start }}-{{ row.priceResult.end }}{{ row.priceResult.chargeType=='VOLUME'? 'Cbm': row.priceResult.weightUnit }} 区间价 {{ row.priceResult.amount }}
      </div>
    </div>

    <!--    单价-->
    <div  class="price-detail-class"  v-if="row.priceResult.viewType === 'SINGLE' && row.priceResult.chargeType !== 'EXPRESSION' ">
      <div class="price-detail-left-class">计算方式:</div>
      <div v-if="row.priceResult.chargeType == 'PERCENT'"  class="price-detail-right-class" >
        {{ row.serviceCode == 'INSURANCE' ? '投保金额': '订单金额'}}
        {{ row.priceResult.calNums }} * {{ row.priceResult.price }}% </div>
<!--      <div v-else-if="row.priceResult.chargeType == 'CAL_WEIGHT' || row.priceResult.chargeType == 'WEIGHT' ||row.priceResult.chargeType == 'VOLUME' " class="price-detail-right-class" >-->
<!--        -->
<!--      </div>-->
      <div   class="price-detail-right-class">
        单价 {{ row.priceResult.price }} * {{getChargeUnitBy(row.priceResult.chargeType)}} {{ row.priceResult.calNums }}{{getChargeUnitName(row.priceResult.chargeType, row.priceResult.weightUnit)}}
      </div>
    </div>


    <!-- 表达式 -->
    <div  class="price-detail-class"  v-if="row.priceResult.viewType === 'EXPRESSION'">

    </div>

    <!-- 仓租  -->
    <div class="price-detail-class" v-show="row.billCategory === 'TENANT'">
      <div class="price-detail-left-class">计算方式:</div>
      <div class="price-detail-right-class" >{{ $tt("tip_warehouse_rent_complete") }}</div>
    </div>

    <!-- 汇率 -->
    <div v-if="row.priceResult.targetCurrency" class="price-detail-class">
      <div class="price-detail-left-class">币种汇率:</div>
      <div  class="price-detail-right-class" >
        交易币 {{row.priceResult.currency}} 兑本币 {{row.priceResult.targetCurrency}} 汇率: {{row.priceResult.rate}}
      </div>
    </div>



  </div>
</template>
<script>

  import Vue from 'vue'

  export default {
    data() {
      return {

      }
    },
    created() {

    },

    watch: {
      value: function (val, old) {
        if (val) {
          this.selectValue = val
        } else {
          this.selectValue = ''
        }
      }
    },

    destroyed() {

    },

    computed: {},

    updated() {
    },

    methods: {
      getChargeUnitName(chargeType, weightUnit){
        if(chargeType == 'CAL_WEIGHT' || chargeType == 'WEIGHT'){
          return ' ' + weightUnit
        }
        else if(chargeType == 'VOLUME'){
          return 'CBM'
        }
        return ''
      },

      getChargeUnitBy(chargeType){

        if(chargeType == 'CAL_WEIGHT' || chargeType == 'WEIGHT'){
          return '重量'
        }
        else if(chargeType == 'VOLUME'){
          return '体积'
        }
        else if(chargeType == 'PACKAGE'){
          return '包裹数'
        }
        else if(chargeType == 'PERCENT'){
          return '百分比'
        }
        else if(chargeType == 'PCS'){
          return 'SKU件数'
        }
        else if(chargeType == 'BOX'){
          return '箱数'
        }
        else if(chargeType == 'ORDER'){
          return '订单数'
        }
        else {
          return ''
        }

      },

    },
    props: {
      row: {
        type: Object,
        default: {}
      },

    }




  }

</script>

<style>


  .price-detail-class{
    display: flex;  gap: 6px;
  }

  .price-detail-left-class{
    width: 68px; text-align: right;
  }

  .price-detail-right-class{
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    flex: 1;
    text-align: left;
  }

</style>
